<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
  <meta name="generator" content="Hugo 0.82.1" />
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="[Golang] 数据类型#数据类型#常量#// bool: true true // bool: false false // null nil // any type interface{} 布尔类型#x bool = true; 整数、浮点数、虚数、复数类型#   type comment     uint8 unsigned 8-bit integers (0 to 255)   uint16 unsigned 16-bit integers (0 to 65535)   uint32 unsigned 32-bit integers (0 to 4294967295)   uint64 unsigned 64-bit integers (0 to 18446744073709551615)   int8 signed 8-bit integers (-128 to 127)   int16 signed 16-bit integers (-32768 to 32767)   int32 signed 32-bit integers (-2147483648 to 2147483647)   int64 signed 64-bit integers (-9223372036854775808 to 9223372036854775807)   float32 IEEE-754 32-bit floating-point numbers   float64 IEEE-754 64-bit floating-point numbers   complex64 complex numbers with float32 real and imaginary parts   complex128 complex numbers with float64 real and imaginary parts    特殊整数类型">
<meta name="theme-color" content="#FFFFFF"><meta property="og:title" content="" />
<meta property="og:description" content="[Golang] 数据类型#数据类型#常量#// bool: true true // bool: false false // null nil // any type interface{} 布尔类型#x bool = true; 整数、浮点数、虚数、复数类型#   type comment     uint8 unsigned 8-bit integers (0 to 255)   uint16 unsigned 16-bit integers (0 to 65535)   uint32 unsigned 32-bit integers (0 to 4294967295)   uint64 unsigned 64-bit integers (0 to 18446744073709551615)   int8 signed 8-bit integers (-128 to 127)   int16 signed 16-bit integers (-32768 to 32767)   int32 signed 32-bit integers (-2147483648 to 2147483647)   int64 signed 64-bit integers (-9223372036854775808 to 9223372036854775807)   float32 IEEE-754 32-bit floating-point numbers   float64 IEEE-754 64-bit floating-point numbers   complex64 complex numbers with float32 real and imaginary parts   complex128 complex numbers with float64 real and imaginary parts    特殊整数类型" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://example.org/docs/data-types/" /><meta property="article:section" content="docs" />



<title>Data Types | My Golang Book</title>
<link rel="manifest" href="/manifest.json">
<link rel="icon" href="/favicon.png" type="image/x-icon">
<link rel="stylesheet" href="/book.min.2bc2364a4a4b31f0ec1debecf0a8f90a840821f143dfe1ac6a0f7cbcbdcf64ac.css" integrity="sha256-K8I2SkpLMfDsHevs8Kj5CoQIIfFD3&#43;Gsag98vL3PZKw=">
<script defer src="/en.search.min.84ce9693e6c02d95376f29aeb794c11824d09ed0440f910f008e91e9ed0436e4.js" integrity="sha256-hM6Wk&#43;bALZU3bymut5TBGCTQntBED5EPAI6R6e0ENuQ="></script>
<!--
Made with Book Theme
https://github.com/alex-shpak/hugo-book
-->

  
</head>

<body dir="ltr">
  <input type="checkbox" class="hidden toggle" id="menu-control" />
  <input type="checkbox" class="hidden toggle" id="toc-control" />
  <main class="container flex">
    <aside class="book-menu">
      <div class="book-menu-content">
        
  <nav>
<h2 class="book-brand">
  <a href="/"><span>My Golang Book</span>
  </a>
</h2>


<div class="book-search">
  <input type="text" id="book-search-input" placeholder="Search" aria-label="Search" maxlength="64" data-hotkeys="s/" />
  <div class="book-search-spinner hidden"></div>
  <ul id="book-search-results"></ul>
</div>











  



  
  <ul>
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/introduction/" class="">Golang 介绍</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/installation/" class="">安装、准备开发环境</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/go-routine/" class="">并发处理 - Go 协程</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/workspace-module/" class="">管理Go模块</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/erro-handling/" class="">错误处理</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/resources/" class="">Golang 资源</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/statements/" class="">Go For语句</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/guidelines/" class="">Go 开发规范</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/logging/" class="">日志</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/data-init/" class="">Data Init</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/data-types/" class=" active">Data Types</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/debug/" class="">Debug</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/dynamic-programing/" class="">Dynamic Programing</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/ecosystem/" class="">Ecosystem</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/performance/" class="">Performance</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/struct-interface/" class="">Struct Interface</a>
  

        </li>
      
    
      
        <li>
          
  
  

  
    <a href="http://example.org/docs/struct-tags/" class="">Struct Tags</a>
  

        </li>
      
    
  </ul>















</nav>




  <script>(function(){var a=document.querySelector("aside.book-menu nav");addEventListener("beforeunload",function(b){localStorage.setItem("menu.scrollTop",a.scrollTop)}),a.scrollTop=localStorage.getItem("menu.scrollTop")})()</script>


 
      </div>
    </aside>

    <div class="book-page">
      <header class="book-header">
        
  <div class="flex align-center justify-between">
  <label for="menu-control">
    <img src="/svg/menu.svg" class="book-icon" alt="Menu" />
  </label>

  <strong>Data Types</strong>

  <label for="toc-control">
    
    <img src="/svg/toc.svg" class="book-icon" alt="Table of Contents" />
    
  </label>
</div>


  
  <aside class="hidden clearfix">
    
  
<nav id="TableOfContents">
  <ul>
    <li><a href="#数据类型">数据类型</a>
      <ul>
        <li><a href="#常量">常量</a></li>
        <li><a href="#布尔类型">布尔类型</a></li>
        <li><a href="#整数浮点数虚数复数类型">整数、浮点数、虚数、复数类型</a></li>
        <li><a href="#字符串类型">字符串类型</a></li>
        <li><a href="#数组类型">数组类型</a></li>
        <li><a href="#切片类型">切片类型</a></li>
        <li><a href="#结构类型">结构类型</a></li>
        <li><a href="#指针类型">指针类型</a></li>
        <li><a href="#函数类型">函数类型</a></li>
        <li><a href="#接口类型">接口类型</a></li>
        <li><a href="#map-types">Map types</a></li>
        <li><a href="#channel-types">Channel types</a></li>
      </ul>
    </li>
  </ul>
</nav>



  </aside>
  
 
      </header>

      
      
  <article class="markdown"><h1 id="golang-数据类型">
  [Golang] 数据类型
  <a class="anchor" href="#golang-%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b">#</a>
</h1>
<h2 id="数据类型">
  数据类型
  <a class="anchor" href="#%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b">#</a>
</h2>
<h3 id="常量">
  常量
  <a class="anchor" href="#%e5%b8%b8%e9%87%8f">#</a>
</h3>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#75715e">// bool: true
</span><span style="color:#75715e"></span><span style="color:#66d9ef">true</span>

<span style="color:#75715e">// bool: false
</span><span style="color:#75715e"></span><span style="color:#66d9ef">false</span>

<span style="color:#75715e">// null
</span><span style="color:#75715e"></span><span style="color:#66d9ef">nil</span>

<span style="color:#75715e">// any type
</span><span style="color:#75715e"></span><span style="color:#66d9ef">interface</span>{}
</code></pre></div><h3 id="布尔类型">
  布尔类型
  <a class="anchor" href="#%e5%b8%83%e5%b0%94%e7%b1%bb%e5%9e%8b">#</a>
</h3>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#a6e22e">x</span> <span style="color:#66d9ef">bool</span> = <span style="color:#66d9ef">true</span>;
</code></pre></div><h3 id="整数浮点数虚数复数类型">
  整数、浮点数、虚数、复数类型
  <a class="anchor" href="#%e6%95%b4%e6%95%b0%e6%b5%ae%e7%82%b9%e6%95%b0%e8%99%9a%e6%95%b0%e5%a4%8d%e6%95%b0%e7%b1%bb%e5%9e%8b">#</a>
</h3>
<table>
<thead>
<tr>
<th>type</th>
<th>comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>uint8</td>
<td>unsigned 8-bit integers (0 to 255)</td>
</tr>
<tr>
<td>uint16</td>
<td>unsigned 16-bit integers (0 to 65535)</td>
</tr>
<tr>
<td>uint32</td>
<td>unsigned 32-bit integers (0 to 4294967295)</td>
</tr>
<tr>
<td>uint64</td>
<td>unsigned 64-bit integers (0 to 18446744073709551615)</td>
</tr>
<tr>
<td>int8</td>
<td>signed 8-bit integers (-128 to 127)</td>
</tr>
<tr>
<td>int16</td>
<td>signed 16-bit integers (-32768 to 32767)</td>
</tr>
<tr>
<td>int32</td>
<td>signed 32-bit integers (-2147483648 to 2147483647)</td>
</tr>
<tr>
<td>int64</td>
<td>signed 64-bit integers (-9223372036854775808 to 9223372036854775807)</td>
</tr>
<tr>
<td>float32</td>
<td>IEEE-754 32-bit floating-point numbers</td>
</tr>
<tr>
<td>float64</td>
<td>IEEE-754 64-bit floating-point numbers</td>
</tr>
<tr>
<td>complex64</td>
<td>complex numbers with float32 real and imaginary parts</td>
</tr>
<tr>
<td>complex128</td>
<td>complex numbers with float64 real and imaginary parts</td>
</tr>
</tbody>
</table>
<p>特殊整数类型</p>
<table>
<thead>
<tr>
<th>type</th>
<th>comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>byte</td>
<td>alias for uint8</td>
</tr>
<tr>
<td>rune</td>
<td>alias for int32</td>
</tr>
<tr>
<td>uint</td>
<td>either 32 or 64 bits</td>
</tr>
<tr>
<td>int</td>
<td>same size as uint</td>
</tr>
<tr>
<td>uintptr</td>
<td>an unsigned integer large enough to store the uninterpreted bits of a pointer value</td>
</tr>
</tbody>
</table>
<h3 id="字符串类型">
  字符串类型
  <a class="anchor" href="#%e5%ad%97%e7%ac%a6%e4%b8%b2%e7%b1%bb%e5%9e%8b">#</a>
</h3>
<p>字符串类型 不可变</p>
<table>
<thead>
<tr>
<th>operation</th>
<th>comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>len(s)</td>
<td>The length of a string</td>
</tr>
<tr>
<td>s[i]</td>
<td>the ith element of the string</td>
</tr>
</tbody>
</table>
<h3 id="数组类型">
  数组类型
  <a class="anchor" href="#%e6%95%b0%e7%bb%84%e7%b1%bb%e5%9e%8b">#</a>
</h3>
<p>go 数组是一维的。通过组合的方式支持多维数组。
数组的长度是固定的。</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go">[<span style="color:#ae81ff">32</span>]<span style="color:#66d9ef">byte</span>
[<span style="color:#ae81ff">2</span><span style="color:#f92672">*</span><span style="color:#a6e22e">N</span>] <span style="color:#66d9ef">struct</span> { <span style="color:#a6e22e">x</span>, <span style="color:#a6e22e">y</span> <span style="color:#66d9ef">int32</span> }
[<span style="color:#ae81ff">1000</span>]<span style="color:#960050;background-color:#1e0010">\</span><span style="color:#f92672">*</span><span style="color:#66d9ef">float64</span>
[<span style="color:#ae81ff">3</span>][<span style="color:#ae81ff">5</span>]<span style="color:#66d9ef">int</span>
[<span style="color:#ae81ff">2</span>][<span style="color:#ae81ff">2</span>][<span style="color:#ae81ff">2</span>]<span style="color:#66d9ef">float64</span> <span style="color:#75715e">// same as [2](&lt;[2]([2]float64)&gt;)
</span></code></pre></div><table>
<thead>
<tr>
<th>operation</th>
<th>comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>len(arr)</td>
<td>The length of an array</td>
</tr>
<tr>
<td>arr[i]</td>
<td>the ith element of the array</td>
</tr>
</tbody>
</table>
<h3 id="切片类型">
  切片类型
  <a class="anchor" href="#%e5%88%87%e7%89%87%e7%b1%bb%e5%9e%8b">#</a>
</h3>
<p>切片是数组的一个连续段。所以切片的初始化，实际上会初始化一个数组。
不同于数组，切片的长度是可变的。</p>
<table>
<thead>
<tr>
<th>operation</th>
<th>comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>len(arr)</td>
<td>The length of a slice</td>
</tr>
<tr>
<td>cap(arr)</td>
<td>The capacity of a slice</td>
</tr>
<tr>
<td>arr[i]</td>
<td>the ith element of the slice</td>
</tr>
<tr>
<td>arr = append(arr, el, el2)</td>
<td>append an element the slice</td>
</tr>
<tr>
<td>arr = append(arr, arr2..)</td>
<td>append an array to the slice</td>
</tr>
<tr>
<td>arr2 = copy(arr)</td>
<td>copy the slice</td>
</tr>
</tbody>
</table>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go">make([]<span style="color:#66d9ef">int</span>, <span style="color:#ae81ff">50</span>, <span style="color:#ae81ff">100</span>)
new([<span style="color:#ae81ff">100</span>]<span style="color:#66d9ef">int</span>)[<span style="color:#ae81ff">0</span>:<span style="color:#ae81ff">50</span>]
</code></pre></div><h3 id="结构类型">
  结构类型
  <a class="anchor" href="#%e7%bb%93%e6%9e%84%e7%b1%bb%e5%9e%8b">#</a>
</h3>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#75715e">// Empty An empty struct.
</span><span style="color:#75715e"></span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">Empty</span> <span style="color:#66d9ef">struct</span>{}

<span style="color:#75715e">/*
</span><span style="color:#75715e">SixFields A struct with 6 fields.
</span><span style="color:#75715e">*/</span>
<span style="color:#66d9ef">type</span> <span style="color:#a6e22e">SixFields</span> <span style="color:#66d9ef">struct</span> {
	<span style="color:#a6e22e">x</span>, <span style="color:#a6e22e">y</span> <span style="color:#66d9ef">int</span>
	<span style="color:#a6e22e">u</span>    <span style="color:#66d9ef">float32</span>
	<span style="color:#a6e22e">_</span>    <span style="color:#66d9ef">float32</span> <span style="color:#75715e">// padding
</span><span style="color:#75715e"></span>	<span style="color:#a6e22e">A</span>    <span style="color:#f92672">*</span>[]<span style="color:#66d9ef">int</span>
	<span style="color:#a6e22e">F</span>    <span style="color:#66d9ef">func</span>()
}

<span style="color:#75715e">// A struct with four embedded fields of types T1, *T2, P.T3 and *P.T4
</span><span style="color:#75715e"></span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">embeddedFields</span> <span style="color:#66d9ef">struct</span> {
	<span style="color:#a6e22e">T1</span>        <span style="color:#75715e">// field name is T1
</span><span style="color:#75715e"></span>	<span style="color:#f92672">*</span><span style="color:#a6e22e">T2</span>       <span style="color:#75715e">// field name is T2
</span><span style="color:#75715e"></span>	<span style="color:#a6e22e">P</span>.<span style="color:#a6e22e">T3</span>      <span style="color:#75715e">// field name is T3
</span><span style="color:#75715e"></span>	<span style="color:#f92672">*</span><span style="color:#a6e22e">P</span>.<span style="color:#a6e22e">T4</span>     <span style="color:#75715e">// field name is T4
</span><span style="color:#75715e"></span>	<span style="color:#a6e22e">x</span>, <span style="color:#a6e22e">y</span>  <span style="color:#66d9ef">int</span> <span style="color:#75715e">// field names are x and y
</span><span style="color:#75715e"></span>}

<span style="color:#66d9ef">type</span> <span style="color:#a6e22e">tagSample</span> <span style="color:#66d9ef">struct</span> {
	<span style="color:#a6e22e">x</span>, <span style="color:#a6e22e">y</span> <span style="color:#66d9ef">float64</span> <span style="color:#e6db74">&#34;&#34;</span> <span style="color:#75715e">// an empty tag string is like an absent tag
</span><span style="color:#75715e"></span>	<span style="color:#a6e22e">name</span> <span style="color:#66d9ef">string</span>  <span style="color:#e6db74">&#34;any string is permitted as a tag&#34;</span>
	<span style="color:#a6e22e">_</span>    [<span style="color:#ae81ff">4</span>]<span style="color:#66d9ef">byte</span> <span style="color:#e6db74">&#34;ceci n&#39;est pas un champ de structure&#34;</span>
}

<span style="color:#75715e">// A struct corresponding to a TimeStamp protocol buffer.
</span><span style="color:#75715e">// The tag strings define the protocol buffer field numbers;
</span><span style="color:#75715e">// they follow the convention outlined by the reflect package.
</span><span style="color:#75715e"></span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">protoBufTags</span> <span style="color:#66d9ef">struct</span> {
	<span style="color:#a6e22e">microsec</span>  <span style="color:#66d9ef">uint64</span> <span style="color:#e6db74">`protobuf:&#34;1&#34;`</span>
	<span style="color:#a6e22e">serverIP6</span> <span style="color:#66d9ef">uint64</span> <span style="color:#e6db74">`protobuf:&#34;2&#34;`</span>
}
</code></pre></div><h3 id="指针类型">
  指针类型
  <a class="anchor" href="#%e6%8c%87%e9%92%88%e7%b1%bb%e5%9e%8b">#</a>
</h3>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#66d9ef">var</span> <span style="color:#f92672">*</span><span style="color:#a6e22e">Point</span> <span style="color:#f92672">*</span>[<span style="color:#ae81ff">4</span>]<span style="color:#66d9ef">int</span>
</code></pre></div><h3 id="函数类型">
  函数类型
  <a class="anchor" href="#%e5%87%bd%e6%95%b0%e7%b1%bb%e5%9e%8b">#</a>
</h3>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#66d9ef">func</span>()
<span style="color:#66d9ef">func</span>(<span style="color:#a6e22e">x</span> <span style="color:#66d9ef">int</span>) <span style="color:#66d9ef">int</span>
<span style="color:#66d9ef">func</span>(<span style="color:#a6e22e">a</span>, <span style="color:#960050;background-color:#1e0010">\</span><span style="color:#a6e22e">_</span> <span style="color:#66d9ef">int</span>, <span style="color:#a6e22e">z</span> <span style="color:#66d9ef">float32</span>) <span style="color:#66d9ef">bool</span>
<span style="color:#66d9ef">func</span>(<span style="color:#a6e22e">a</span>, <span style="color:#a6e22e">b</span> <span style="color:#66d9ef">int</span>, <span style="color:#a6e22e">z</span> <span style="color:#66d9ef">float32</span>) (<span style="color:#66d9ef">bool</span>)
<span style="color:#66d9ef">func</span>(<span style="color:#a6e22e">prefix</span> <span style="color:#66d9ef">string</span>, <span style="color:#a6e22e">values</span> <span style="color:#f92672">...</span><span style="color:#66d9ef">int</span>)
<span style="color:#66d9ef">func</span>(<span style="color:#a6e22e">a</span>, <span style="color:#a6e22e">b</span> <span style="color:#66d9ef">int</span>, <span style="color:#a6e22e">z</span> <span style="color:#66d9ef">float64</span>, <span style="color:#a6e22e">opt</span> <span style="color:#f92672">...</span><span style="color:#66d9ef">interface</span>{}) (<span style="color:#a6e22e">success</span> <span style="color:#66d9ef">bool</span>)
<span style="color:#66d9ef">func</span>(<span style="color:#66d9ef">int</span>, <span style="color:#66d9ef">int</span>, <span style="color:#66d9ef">float64</span>) (<span style="color:#66d9ef">float64</span>, <span style="color:#f92672">*</span>[]<span style="color:#66d9ef">int</span>)
<span style="color:#66d9ef">func</span>(<span style="color:#a6e22e">n</span> <span style="color:#66d9ef">int</span>) <span style="color:#66d9ef">func</span>(<span style="color:#a6e22e">p</span> <span style="color:#f92672">*</span><span style="color:#a6e22e">T</span>)
</code></pre></div><h3 id="接口类型">
  接口类型
  <a class="anchor" href="#%e6%8e%a5%e5%8f%a3%e7%b1%bb%e5%9e%8b">#</a>
</h3>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#75715e">// SimpleFile file reader
</span><span style="color:#75715e"></span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">SimpleFile</span> <span style="color:#66d9ef">interface</span> {
	<span style="color:#a6e22e">Read</span>([]<span style="color:#66d9ef">byte</span>) (<span style="color:#66d9ef">int</span>, <span style="color:#66d9ef">error</span>)
	<span style="color:#a6e22e">Write</span>([]<span style="color:#66d9ef">byte</span>) (<span style="color:#66d9ef">int</span>, <span style="color:#66d9ef">error</span>)
	<span style="color:#a6e22e">Close</span>() <span style="color:#66d9ef">error</span>
}

<span style="color:#75715e">// Reader file reader
</span><span style="color:#75715e"></span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">Reader</span> <span style="color:#66d9ef">interface</span> {
	<span style="color:#a6e22e">Read</span>(<span style="color:#a6e22e">p</span> []<span style="color:#66d9ef">byte</span>) (<span style="color:#a6e22e">n</span> <span style="color:#66d9ef">int</span>, <span style="color:#a6e22e">err</span> <span style="color:#66d9ef">error</span>)
	<span style="color:#a6e22e">Close</span>() <span style="color:#66d9ef">error</span>
}

<span style="color:#75715e">// Writer file writter
</span><span style="color:#75715e"></span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">Writer</span> <span style="color:#66d9ef">interface</span> {
	<span style="color:#a6e22e">Write</span>(<span style="color:#a6e22e">p</span> []<span style="color:#66d9ef">byte</span>) (<span style="color:#a6e22e">n</span> <span style="color:#66d9ef">int</span>, <span style="color:#a6e22e">err</span> <span style="color:#66d9ef">error</span>)
	<span style="color:#a6e22e">Close</span>() <span style="color:#66d9ef">error</span>
}

<span style="color:#75715e">// ReadWriter 联合结果 Read, Write, and Close.
</span><span style="color:#75715e"></span><span style="color:#66d9ef">type</span> <span style="color:#a6e22e">ReadWriter</span> <span style="color:#66d9ef">interface</span> {
	<span style="color:#a6e22e">Reader</span> <span style="color:#75715e">// includes methods of Reader in ReadWriter&#39;s method set
</span><span style="color:#75715e"></span>	<span style="color:#a6e22e">Writer</span> <span style="color:#75715e">// includes methods of Writer in ReadWriter&#39;s method set
</span><span style="color:#75715e"></span>}
</code></pre></div><h3 id="map-types">
  Map types
  <a class="anchor" href="#map-types">#</a>
</h3>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#66d9ef">map</span>[<span style="color:#66d9ef">string</span>]<span style="color:#66d9ef">int</span>
<span style="color:#66d9ef">map</span>[<span style="color:#f92672">*</span><span style="color:#a6e22e">T</span>]<span style="color:#66d9ef">struct</span>{ <span style="color:#a6e22e">x</span>, <span style="color:#a6e22e">y</span> <span style="color:#66d9ef">float64</span> }
<span style="color:#66d9ef">map</span>[<span style="color:#66d9ef">string</span>]<span style="color:#66d9ef">interface</span>{}


make(<span style="color:#66d9ef">map</span>[<span style="color:#66d9ef">string</span>]<span style="color:#66d9ef">int</span>)
make(<span style="color:#66d9ef">map</span>[<span style="color:#66d9ef">string</span>]<span style="color:#66d9ef">int</span>, <span style="color:#ae81ff">100</span>)
</code></pre></div><h3 id="channel-types">
  Channel types
  <a class="anchor" href="#channel-types">#</a>
</h3>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#66d9ef">chan</span> <span style="color:#a6e22e">T</span> <span style="color:#75715e">// can be used to send and receive values of type T
</span><span style="color:#75715e"></span><span style="color:#66d9ef">chan</span><span style="color:#f92672">&lt;-</span> <span style="color:#66d9ef">float64</span> <span style="color:#75715e">// can only be used to send float64s
</span><span style="color:#75715e"></span><span style="color:#f92672">&lt;-</span><span style="color:#66d9ef">chan</span> <span style="color:#66d9ef">int</span> <span style="color:#75715e">// can only be used to receive ints
</span><span style="color:#75715e"></span>

<span style="color:#66d9ef">chan</span><span style="color:#f92672">&lt;-</span> <span style="color:#66d9ef">chan</span> <span style="color:#66d9ef">int</span> <span style="color:#75715e">// same as chan&lt;- (chan int)
</span><span style="color:#75715e"></span><span style="color:#66d9ef">chan</span><span style="color:#f92672">&lt;-</span> <span style="color:#f92672">&lt;-</span><span style="color:#66d9ef">chan</span> <span style="color:#66d9ef">int</span> <span style="color:#75715e">// same as chan&lt;- (&lt;-chan int)
</span><span style="color:#75715e"></span><span style="color:#f92672">&lt;-</span><span style="color:#66d9ef">chan</span> <span style="color:#f92672">&lt;-</span><span style="color:#66d9ef">chan</span> <span style="color:#66d9ef">int</span> <span style="color:#75715e">// same as &lt;-chan (&lt;-chan int)
</span><span style="color:#75715e"></span><span style="color:#66d9ef">chan</span> (<span style="color:#f92672">&lt;-</span><span style="color:#66d9ef">chan</span> <span style="color:#66d9ef">int</span>)

make(<span style="color:#66d9ef">chan</span> <span style="color:#66d9ef">int</span>, <span style="color:#ae81ff">100</span>)
</code></pre></div></article>
 
      

      <footer class="book-footer">
        
  <div class="flex flex-wrap justify-between">





</div>

 
        
      </footer>

      
  
  <div class="book-comments">

</div>
  
 

      <label for="menu-control" class="hidden book-menu-overlay"></label>
    </div>

    
    <aside class="book-toc">
      <div class="book-toc-content">
        
  
<nav id="TableOfContents">
  <ul>
    <li><a href="#数据类型">数据类型</a>
      <ul>
        <li><a href="#常量">常量</a></li>
        <li><a href="#布尔类型">布尔类型</a></li>
        <li><a href="#整数浮点数虚数复数类型">整数、浮点数、虚数、复数类型</a></li>
        <li><a href="#字符串类型">字符串类型</a></li>
        <li><a href="#数组类型">数组类型</a></li>
        <li><a href="#切片类型">切片类型</a></li>
        <li><a href="#结构类型">结构类型</a></li>
        <li><a href="#指针类型">指针类型</a></li>
        <li><a href="#函数类型">函数类型</a></li>
        <li><a href="#接口类型">接口类型</a></li>
        <li><a href="#map-types">Map types</a></li>
        <li><a href="#channel-types">Channel types</a></li>
      </ul>
    </li>
  </ul>
</nav>


 
      </div>
    </aside>
    
  </main>

  
</body>

</html>












